package com.example.demo20250926;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author sky
 * @date 2025年09月26日 10:57
 * @description
 * @since 1.0.0
 */
@Configuration
@EnableSwagger2
public class Swagger2Config{
    private static final String SWAGGER_SCAN_BASE_PACKAGE = "com.example.demo20250926";
    private static final String VERSION = "1.0.0";
    private static final String TITLE = "SpringBoot2.6.x Demo";
    private static final String DESCRIPTION = "SpringBoot2.6.x Demo";
    private static final String CONTACT_NAME = "sky";
    private static final String CONTACT_URL = "https://github.com/sky-wei";
    private static final String CONTACT_EMAIL = "";
    private static final String LICENSE = "MIT";
    private static final String LICENSE_URL = "https://github.com/sky-wei";
    private static final String BASE_PACKAGE = "com.example.demo20250926";
    private static final String[] PATH_PATTERNS = new String[]{"**"};
    private static final String[] EXCLUDE_PATH_PATTERNS = new String[]{"/error"};
    private static final String[] EXCLUDE_PATH_PATTERNS_REGEX = new String[]{"/error"};
    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        .title(TITLE)
                        .description(DESCRIPTION)
                        .contact(new Contact(CONTACT_NAME, CONTACT_URL, CONTACT_EMAIL))
                        .license(LICENSE)
                        .licenseUrl(LICENSE_URL)
                        .version(VERSION)
                        .build())
                .select()
                .apis(RequestHandlerSelectors.basePackage(SWAGGER_SCAN_BASE_PACKAGE))
                .paths(PathSelectors.any())
                .build();
    }
}
